
function c(){
    let li = document.querySelectorAll(".to > li");
//总价
    let all = document.querySelector(".sp1");
    let sum = 0;
    for (let i = 0; i < li.length; i++){
        var price = li[i].children[1].children[0].innerHTML;
        var num = li[i].children[1].children[1].value;
        var total = li[i].children[1].children[3].innerHTML = price * num;
        /*    console.log(li[i].children[1].children[0]);
         console.log(li[i].children[1].children[1]);*/
        console.log(li[i].children[1].children[3]);
        sum += total;
    }
    console.log(sum);
    all.innerHTML = sum.toFixed(2);
}
c();
var to = document.querySelector(".to");
var bu = document.querySelector(".bu");
//只要数量的input内容发生改变，小计和总价就要更新
let num_all = document.querySelectorAll(".to .text");
for (let j = 0; j < num_all.length; j++){
    num_all[j].addEventListener('change',c);
}
//删除操作后，再根据小计计算总价
let del_all = document.querySelectorAll(".to .delete");
for (let k = 0; k < del_all.length; k++){
    del_all[k].addEventListener('click',function(){
        to.removeChild(this.parentNode);
        bu.innerHTML = Number(bu.innerHTML) - 1;
        c();
    })
}
